<?php
    include_once 'connection/databaseHandler.php';
    include_once 'connection/sessionHandler.php';
    $database = new DatabaseHandler();
    $session = new SessionHandler();

    if (isset($_GET['id'])) {
        $act_username = $_GET['id'];
        $act_username = stripslashes($act_username);
        $act_username = mysql_real_escape_string($act_username);
        $query = "SELECT * FROM ".$database->t_user." WHERE username='".$act_username."'";
        $result = $database->execQuery($query);
        $count = mysql_num_rows($result);
        if($count==1){
            $result = mysql_fetch_array($result);
            $actID = $result;
        }
        else {
            $actID = $session->activeUser;
        }
    }
    else {
        if (!$session->isLoggedIn) {
            header("location:index.php");
            die();
        }
        $actID = $session->activeUser;
    }

    include_once 'classes/cSetting.php';
    $thisPage = new Setting($database,$session,$actID);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>Register</title>
        <link href="style/style_general.css" rel="stylesheet" type="text/css"/>
        <link href="style/style_register.css" rel="stylesheet" type="text/css"/>
        <link href="style/style_chat.css" rel="stylesheet" type="text/css"/>
        <link href="style/style_notif.css" rel="stylesheet" type="text/css"/>
        <script type="text/javascript" src="script/AJAX.js"></script>
        <script type="text/javascript" src="script/chat.js"></script>
        <script type="text/javascript" src="script/notif.js"></script>
        <script type="text/javascript" src="script/validator.js"></script>
        <script type="text/javascript" src="script/calendar.js"></script>
    </head>

    <body>
        <?php
            if ($session->isLoggedIn) {
                echo "<script language=javascript>initChat()</script>";
                echo "<script language=javascript>initNotif()</script>";
            }
            include 'layout/general_layout/header.php';
            $thisPage->genHeader();            
            include 'layout/setting_layout/setting_content.php';
            include 'layout/general_layout/footer.php';
        ?>
    </body>
</html>
